DATA SEGMENT
DATA ENDS
;
STAC SEGMENT PARA STACK
STAC ENDS
;
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START PROC FAR
     ORG 100H;
     MOV DX,8006H;	
     MOV AL,88H;
     OUT DX,AL;

 MAIN:
	MOV DX,8004H;	
     MOV AL,0F1H;
     OUT DX,AL;
  
	MOV BX,0000H;
	MOV AX,0000H;
     MOV CX,0AH; 

     MOV DX,8004H;	
     MOV AL,0F0H;
     OUT DX,AL;

     NOP;
     NOP;
     NOP;
     NOP;
     NOP;
     NOP;

 S02:MOV DX,8004H;	
      MOV AL,0F2H;
      OUT DX,AL;
 	
     MOV DX,8004H;
     IN AL,DX;

     PUSH AX;
     MOV DX,8004H;	
     MOV AL,0F0H;
     OUT DX,AL;
     POP AX;

     AND AX,0010H;
     JE S01;
     OR BX,01H;
 S01:SHL BX,01;

     LOOP S02;
	 
	 SHR BX,1
	 
	MOV DX,8004H;	
     MOV AL,0F1H;
     OUT DX,AL;
	 
	PUSH BX
	AND BX,0200H
	POP BX
	PUSH BX
	JNZ S00
	;
	MOV DX,8002H
	MOV AL,01H
	OUT DX,AL
	MOV DX,8000H
	MOV AL,0FFH
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	JMP ZS
S00:	
	MOV DX,8002H
	MOV AL,01H
	OUT DX,AL
	MOV DX,8000H
	MOV AL,0BFH
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	;
	POP BX
	DEC BX
	XOR BX,03FFH
ZS:
	SHR BX,1
	JNC SHOWZERO
SHOWFIVE:
	MOV DX,8002H
	MOV AL,08H
	OUT DX,AL
	MOV DX,8000H
	MOV AL,92H
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	
	JMP THIRD
	;
SHOWZERO:
	MOV DX,8002H
	MOV AL,08H
	OUT DX,AL
	MOV DX,8000H
	MOV AL,0C0H
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	;
THIRD:
	MOV AX,BX
	MOV BL,0AH
	DIV BL
	;
	PUSH AX
	MOV DX,8002H
	MOV AL,02H
	OUT DX,AL
	POP AX
	PUSH AX
	AND AX,00FFH
	MOV DX,8000H
	CALL DISPALY
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	
	POP AX 
	PUSH AX
	MOV DX,8002H
	MOV AL,04H
	OUT DX,AL
	POP AX
	MOV AL,AH
	AND AX,00FFH
	MOV DX,8000H
	CALL DISPALY
	AND AL,7FH
	OUT DX,AL
	CALL DELAY
	CALL SEGOFF
	;
	JMP MAIN
	;	

	 NSEG DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH
	 DSEG DB 40H,79H,24H,30H,19H,12H,02H,78H,00H,10H,08H,03H,46H,21H,06H,0EH
 START ENDP;

 DELAY PROC
     MOV CX,001AH;
 S99:NOP;
     NOP;
     LOOP S99;
     RET
  DELAY ENDP;
  
  SEGOFF PROC
	MOV DX,8000H;
	MOV AL,0FFH;
	OUT DX,AL;
	RET;
  SEGOFF ENDP;
  
  DISPALY PROC
	 CMP AL,00H;
	 JNE NUM1;
	 MOV AL,0C0H;
	 JMP ENNUM;
NUM1:CMP AL,01H;
	 JNE NUM2;
	 MOV AL,0F9H;
	 JMP ENNUM;
NUM2:CMP AL,02H;
	 JNE NUM3;
	 MOV AL,0A4H;
	 JMP ENNUM;
NUM3:CMP AL,03H;
	 JNE NUM4;
	 MOV AL,0B0H;
	 JMP ENNUM;
NUM4:CMP AL,04H;
	 JNE NUM5;
	 MOV AL,99H;
	 JMP ENNUM;
NUM5:CMP AL,05H;
	 JNE NUM6;
	 MOV AL,92H;
	 JMP ENNUM;
NUM6:CMP AL,06H;
	 JNE NUM7;
	 MOV AL,82H;
	 JMP ENNUM;
NUM7:CMP AL,07H;
	 JNE NUM8;
	 MOV AL,0F8H;
	 JMP ENNUM;
NUM8:CMP AL,08H;
	 JNE NUM9;
	 MOV AL,80H;
	 JMP ENNUM;
NUM9:MOV AL,90H;
ENNUM:NOP;
     RET;
DISPALY ENDP
;
 CODE ENDS;
 END START;
